"""
step1：打开文件
    表示和文件建立连接

step2：读取数据，写出数据

step3：关闭文件
    断开连接
"""
# IO stream  IO 流
#
# # 绝对路径
# file_path = r'C:\Users\Administrator\Desktop\lifegame.txt'
# # file_path2 = 'E:\lifegame.txt'
# # f = open(file_path2)
# f = open(file_path)
# print(f.read())
# # 关闭文件
# f.close()

# 相对路径

# # file_path = 'path2.txt'
# file_path = r'file1\file.txt'
# f = open(file_path)
# print(f.read())
# f.close()


# file_path = r'file1\file.txt'
# f = open(file_path)
# # print(f.read()) # 没参数,就默认读取 所有, 有参数n 就读 n个字符
# # print(f.readline())  # 每次读一行
# res = f.readlines()
# print(type(res))
# f.close()

# file_path = r'file1\file.txt'
# f = open(file_path)
# res = True
# while res:
#     res = f.read(10)
#     print(res, end='')
# f.close()

# file_path = r'file1\file.txt'
# f = open(file_path)
# res = True
# while res:
#     res = f.readline()
#     print(res, end='')
# f.close()

file_path = r'file1\file.txt'
f = open(file_path)
for i in f:
    print(i)
f.close()


